<template>
	<view class="all-box containers" style="margin-bottom:200rpx;">
		<view v-if="netWorkType!='none'">
			<tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx"></tui-skeleton>
			<view class="container tui-skeleton">
				<view class="record-list" v-for="(item,index) in data.list">
					<view class="pad-all15 font12" style="padding-bottom: 15rpx;">{{data.list_key[index]}}</view>

					<view class="every-day-record bg-white marginleft15 marginright15 padbottom10 border-radius4">
						<view v-for="(row,j) in item" @tap="detail(row.id)" class="row-block">
							<view class="flex-box pad-all10" style="padding-bottom: 0;">
								<view class="flex-start-box" :class="[fromFather.product_type==5 && j>0?'border-two':'']">
									<!-- 血压 -->
									<view v-if="fromFather.product_type==1">
										<tui-tag v-if="row.sp<140" size="small" padding="12rpx" type="dev-green"  >正常</tui-tag>
										<tui-tag v-else size="small" padding="12rpx" type="dev-red" >异常</tui-tag>
									 
										<view class="padtop5 font21" style="font-weight: 700;" v-if="fromFather.product_type==1" >{{row.sp}}/{{row.dp}}</view>
										 
									</view>
									<!-- 血糖 -->
									<view  v-else-if="fromFather.product_type==3">
										<view>
											<tui-tag size="small" padding="12rpx" type="dev-green" v-if="row.status==1">正常</tui-tag>
											<tui-tag size="small" padding="12rpx" type="dev-red" v-else-if="row.status==2">异常</tui-tag>
											<tui-tag size="small" padding="12rpx" type="dev-red" v-else="row.status==3">异常</tui-tag>
											<view class="font12 font-gray" style="display: inline-block;padding-left: 20rpx;">{{row.time}}</view> 
										</view> 
										<view class="padtop5 font21" style="font-weight: 700;">
										{{row.glu}}
										 <text style="font-size: 28rpx; padding-left: 3px;font-weight: 400;">{{row.unit_type_desc}}</text>
										</view>
									</view>
									<!-- 尿酸 -->
									<view  v-else-if="fromFather.product_type==4">
										<view>
											<tui-tag size="small" padding="12rpx" type="dev-green" v-if="row.status==1">正常</tui-tag>
											<tui-tag size="small" padding="12rpx" type="dev-red" v-else-if="row.status==2">异常</tui-tag>
										</view> 
										<view class="padtop5 font21" style="font-weight: 700;" >{{row.ua}}</view>
									</view>
									<view  v-else-if="fromFather.product_type==5" style="display: flex; margin:32rpx 0;height: 100rpx;" >
										<view>
											<img style="width: 60rpx; height: 60rpx;" src="http://img.aiouning.com/uploader/upload/202112/23/2021122309113961c3cccb64df5.png" alt="">
											<view class="box-time">{{row.time}}</view>
										</view> 
										<view  class="fat-box">
											{{row.weightKg}} 
											 <view style="margin-left: 6rpx;">
												 <view class="weight-item"  style="margin-top: 10rpx;">体重</view>
												 <view class="weight-item">kg</view>
											 </view>
											
										</view>
										<view class="fat-box">
											{{row.fat}} 
											<view style="margin-left: 6rpx;">
												<view class="weight-item" style="margin-top: 10rpx;">体脂率</view>
												<view class="weight-item">%</view>
											</view>
										 </view>
									</view>
									
									<view class="padleft5" style="margin-top: -8rpx;" v-if="fromFather.product_type==1">
										<view class="font12 font-gray" style="margin-bottom: 20rpx;">{{row.time}}</view> 
										<view class="font12 padtop5" style="font-weight: 400;" >mmhg</view>
 									</view>
									<view class="padleft10" style="margin-top: -8rpx;" v-if="fromFather.product_type==4">
										<view class="font12 font-gray" style="margin-bottom: 20rpx;">{{row.time}}</view> 
										<view class="font12 padtop5"  style="font-weight: 400;">μmol/L</view>
									</view>
									
									<view class="padleft10" style="position: relative; top: -18px; left: -25px;" v-else>
										<!-- <view class="font12 font-gray">{{row.time}}</view> -->
									</view>
									<view class="padleft30">
										<view class="font12 font-gray" style="height: 32rpx;">
											<!-- 空标签 -->
										</view>
										<view v-if="row.heart" class="padtop5 font21">{{row.heart}}<text class="font12">dpm</text></view>

									</view>
								</view>
								<!-- style="position: relative;top: -15px;" -->
								<view class="iconfont font-gray"  v-if="fromFather.product_type!=5">&#xe62b;</view>
								<view class="iconfont font-gray" v-else>&#xe62b;</view>
							</view>
							<!-- 备注 -->
							<view v-if="row.remark" class="remark margin-all10 font12 pad-all10 border-radius4" style="background-color: #F8FAFC;">
								<view class="over-ellipsis-two">
									{{row.remark || ''}}
									
								</view>

							</view>
						</view>

						<!-- 备注end -->

					</view>

				</view>
			</view>
		</view>
		<!-- 登录弹窗 -->
		<uni-popup-vlogin id="popupvLogin" ref="popupvLogin" type="bottom" />

	</view>
</template>
<script>
	import Vue from 'vue'
	import store from '@/store/index.js';
	// 公共底部
	import btabbar from '@/components/indexBottomTable/bottomtabbar.vue'
	import tuiTag from '@/components/tag/tag'
	import {FormatDate} from '@/utils/base.js'//降序函数
	import {
		mapGetters
	} from 'vuex';
	export default {
		components: {
			btabbar,
			tuiTag
		},
		computed: {
			//注册网络状态
			...mapGetters(['netWorkType', 'loginStatus'])
		},
		data() {
			return {
				// 骨架屏
				skeletonShow: true,
				fromFather: {
					member_id: '',
					product_type:1
				},
				page: {
					currentPage: 1,
					size: 10,
				},


				data: {
					list_key:[],
					list: []
				}
			}
		},
		onLoad(e) {
			console.log('***',e)
			this.fromFather.group_id = e.group_id;
			this.fromFather.product_type = e.product_type;
			 

		},
		onShow() {
			this.getList()

		},
		methods: {
			getList() {
				let _this = this
				let opt = {
					url: '/blutdruck_check/getList',
					method: 'get',
					data: {
						group_id: _this.fromFather.group_id,
						product_type: _this.fromFather.product_type
						// size: this.page.size,
						// page: this.page.currentPage
					},
					success: function(res) {
						// console.log(res)
						if (res.status == 1) {
							_this.skeletonShow = false;
							_this.data.list_key=Object.keys(res.data.list) || [];
							let values=Object.values(res.data.list);
							values.forEach(function(cv){
								
								cv.forEach(function(row){
								
									let check_time=new FormatDate(row.check_time*1000,'H:M2:S').transferTime()
									// let check_time=Format(row.check_time*1000,4);
									row.check_time=check_time;
								})
							})
							_this.data.list=values || [];
							
							
							console.log(values)
						} else {

						}

					}
				};
				if (this.loginStatus) {
					this.$service.GetApi(opt) //网络
				}

			},
			//
			detail(id) {
				let _this = this
				let tourl = '/packageHealthy/pages/test_record/detail'
				if(_this.fromFather.product_type == 5){
					tourl = '/packageWeight/pages/device/scale/test_report/index'
				}
				this.$refer.setVilit(tourl)
				let callback = function(url) {
					_this.$refs.popupvLogin.open()
				}
				var data = {
					id:id

				}
				this.$refer.toUrl(callback, data)

				return

			}

		}
	}
</script>

<style lang="scss">
	@import "./test_record.scss";
</style>
